/*
 * @文件描述: 
 * @版本: 
 * @作者: 周晨阳
 * @Date: 2021-01-19 17:15:17
 */
#ifndef MYSRAM_H
#define MYSRAM_H

#include "public.h"
#ifndef WIN_SIM

//FSMC 一共用了PF,PG,PD,PE,一共40个引脚
//fsmc地址引脚，使用到了PF,PG,PD，一共十九根数据线
#define SRAM_A0_PORT GPIOF
#define SRAM_A0_PIN GPIO_Pin_0

#define SRAM_A1_PORT GPIOF
#define SRAM_A1_PIN GPIO_Pin_1

#define SRAM_A2_PORT GPIOF
#define SRAM_A2_PIN GPIO_Pin_2

#define SRAM_A3_PORT GPIOF
#define SRAM_A3_PIN GPIO_Pin_3

#define SRAM_A4_PORT GPIOF
#define SRAM_A4_PIN GPIO_Pin_4

#define SRAM_A5_PORT GPIOF
#define SRAM_A5_PIN GPIO_Pin_5

#define SRAM_A6_PORT GPIOF
#define SRAM_A6_PIN GPIO_Pin_12

#define SRAM_A7_PORT GPIOF
#define SRAM_A7_PIN GPIO_Pin_13

#define SRAM_A8_PORT GPIOF
#define SRAM_A8_PIN GPIO_Pin_14

#define SRAM_A9_PORT GPIOF
#define SRAM_A9_PIN GPIO_Pin_15

#define SRAM_A10_PORT GPIOG
#define SRAM_A10_PIN GPIO_Pin_0

#define SRAM_A11_PORT GPIOG
#define SRAM_A11_PIN GPIO_Pin_1

#define SRAM_A12_PORT GPIOG
#define SRAM_A12_PIN GPIO_Pin_2

#define SRAM_A13_PORT GPIOG
#define SRAM_A13_PIN GPIO_Pin_3

#define SRAM_A14_PORT GPIOG
#define SRAM_A14_PIN GPIO_Pin_4

#define SRAM_A15_PORT GPIOG
#define SRAM_A15_PIN GPIO_Pin_5

#define SRAM_A16_PORT GPIOD
#define SRAM_A16_PIN GPIO_Pin_11

#define SRAM_A17_PORT GPIOD
#define SRAM_A17_PIN GPIO_Pin_12

#define SRAM_A18_PORT GPIOD
#define SRAM_A18_PIN GPIO_Pin_13

//SRAM的 NBL CS NOE NWE 线
#define SRAM_NBL0_PORT GPIOE
#define SRAM_NBL0_PIN GPIO_Pin_0

#define SRAM_NBL1_PORT GPIOE
#define SRAM_NBL1_PIN GPIO_Pin_1

#define SRAM_CS_PORT GPIOG
#define SRAM_CS_PIN GPIO_Pin_10

#define SRAM_NOE_PORT GPIOD
#define SRAM_NOE_PIN GPIO_Pin_4

#define SRAM_NWE_PORT GPIOD
#define SRAM_NWE_PIN GPIO_Pin_5

//fsmc数据引脚，使用到了PD,PE，和TFT是公用的
#define SRAM_D0_CLK RCC_AHB1Periph_GPIOD
#define SRAM_D0_PORT GPIOD
#define SRAM_D0_PIN GPIO_Pin_14

#define SRAM_D1_CLK RCC_AHB1Periph_GPIOD
#define SRAM_D1_PORT GPIOD
#define SRAM_D1_PIN GPIO_Pin_15

#define SRAM_D2_CLK RCC_AHB1Periph_GPIOD
#define SRAM_D2_PORT GPIOD
#define SRAM_D2_PIN GPIO_Pin_0

#define SRAM_D3_CLK RCC_AHB1Periph_GPIOD
#define SRAM_D3_PORT GPIOD
#define SRAM_D3_PIN GPIO_Pin_1

#define SRAM_D4_CLK RCC_AHB1Periph_GPIOE
#define SRAM_D4_PORT GPIOE
#define SRAM_D4_PIN GPIO_Pin_7

#define SRAM_D5_CLK RCC_AHB1Periph_GPIOE
#define SRAM_D5_PORT GPIOE
#define SRAM_D5_PIN GPIO_Pin_8

#define SRAM_D6_CLK RCC_AHB1Periph_GPIOE
#define SRAM_D6_PORT GPIOE
#define SRAM_D6_PIN GPIO_Pin_9

#define SRAM_D7_CLK RCC_AHB1Periph_GPIOE
#define SRAM_D7_PORT GPIOE
#define SRAM_D7_PIN GPIO_Pin_10

#define SRAM_D8_CLK RCC_AHB1Periph_GPIOE
#define SRAM_D8_PORT GPIOE
#define SRAM_D8_PIN GPIO_Pin_11

#define SRAM_D9_CLK RCC_AHB1Periph_GPIOE
#define SRAM_D9_PORT GPIOE
#define SRAM_D9_PIN GPIO_Pin_12

#define SRAM_D10_CLK RCC_AHB1Periph_GPIOE
#define SRAM_D10_PORT GPIOE
#define SRAM_D10_PIN GPIO_Pin_13

#define SRAM_D11_CLK RCC_AHB1Periph_GPIOE
#define SRAM_D11_PORT GPIOE
#define SRAM_D11_PIN GPIO_Pin_14

#define SRAM_D12_CLK RCC_AHB1Periph_GPIOE
#define SRAM_D12_PORT GPIOE
#define SRAM_D12_PIN GPIO_Pin_15

#define SRAM_D13_CLK RCC_AHB1Periph_GPIOD
#define SRAM_D13_PORT GPIOD
#define SRAM_D13_PIN GPIO_Pin_8

#define SRAM_D14_CLK RCC_AHB1Periph_GPIOD
#define SRAM_D14_PORT GPIOD
#define SRAM_D14_PIN GPIO_Pin_9

#define SRAM_D15_CLK RCC_AHB1Periph_GPIOD
#define SRAM_D15_PORT GPIOD
#define SRAM_D15_PIN GPIO_Pin_10

#endif  
void FSMC_SRAM_Init(void);
void FSMC_SRAM_WriteBuffer(u8* pBuffer,u32 WriteAddr,u32 NumHalfwordToWrite);
void FSMC_SRAM_ReadBuffer(u8* pBuffer,u32 ReadAddr,u32 NumHalfwordToRead);

#endif